//
//  ViewController.swift
//  TSPhotoPicker_Demo
//
//  Created by 6688 on 02/11/2025.
//

import Photos
import TSAIPhotoPicker
import UIKit

class ViewController: UIViewController {
    lazy var button: UIButton = UIButton()

    override func viewDidLoad() {
        super.viewDidLoad()
        addTestButton()
    }

    func addTestButton() {
        button.setTitle("测试按钮", for: .normal)
        button.backgroundColor = .yellow
        button.frame = .init(origin: view.center, size: .init(width: 100, height: 100))
        view.addSubview(button)

        button.addTarget(self, action: #selector(showPhotoPicker), for: .touchUpInside)
    }

    @objc func showPhotoPicker() {
        let vc = TSPhtotPickerViewController(generatedDatas: [], usedDatas: [])

        vc.config.uiconfigs.mainCorner = 18
        vc.config.uiconfigs.tabCorner = 28
        vc.config.features.maxSelectionCount = 10
        vc.config.uiconfigs.bottomPriviewCorner = 8
        vc.config.tipConfig = PhotoPickerConfig.TipConfig(show: true, tipIcon: UIImage(named: "Bob cut")!)
        vc.config.tipConfig.bgCorner = 12
        vc.config.tipConfig.bgColor = .red

        vc.delegate = self
        vc.modalPresentationStyle = .formSheet
        present(vc, animated: true)
    }
}

extension ViewController: TSPickerViewDelegate {
    func didFinishedPickerPhoto(controller: TSAIPhotoPicker.TSPhtotPickerViewController, images: [PHAsset], customData: TSAIPhotoPicker.TSPickerCustomData) {
    }

    func didFinishedPickerPhotoImages(controller: TSAIPhotoPicker.TSPhtotPickerViewController, images: [UIImage], customData: TSAIPhotoPicker.TSPickerCustomData) {
    }
}
